package com.liugan.magic.actor.still;

import com.liugan.magic.actor.base.BaseActor;
import com.liugan.magic.screen.PointXY;
import com.liugan.magic.screen.layer.GameLayer;
import com.liugan.magic.utils.AnimationUtils;

public class Door extends BaseActor{
	
	public Door(PointXY totalXY,PointXY offsetXY){
		this.totalXY.setxy(totalXY);
		this.offsetXY.setxy(offsetXY);
		this.setImage(AnimationUtils.getinstance().door);
		ct.setCT("door",105,0,0,0,0,180,0);//设定属性
	}

	@Override
	public void action(long elapsedTime) {
		if (layer==null){
			layer =(GameLayer)this.getLayer();
		}
		this.setLocation(this.totalXY.x-layer.layerbeginXY.x, this.totalXY.y-layer.layerbeginXY.y);
		
		if (this.isAnimation()){
			if(this.getAnimation().getCurrentFrameIndex()==this.getAnimation().getTotalFrames()-1){
				this.setAnimation(false);
				this.setImage(AnimationUtils.getinstance().door);
				layer.issucceed=true;
			}
		}
	}
	
}
